package com.topInterview;

public class leecode {
    //快慢指针思想
    public int process(int[] arr) {
        if (arr.length < 2) {
            return 0;
        }
        int slow = arr[0];
        int fast = arr[arr[0]];
        while (slow != fast) {
            slow = arr[slow];
            fast = arr[arr[fast]];
        }

        fast = 0;
        while (slow != fast) {
            slow = arr[slow];
            fast = arr[fast];
        }
        return slow;
    }
}
